package com.manbu.springcloud.service;

import com.manbu.springcloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
//import lombok.extern.apachecommons.CommonsLog;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @description:
 * @author: wanghan
 * @time: 2021/4/22 下午8:19
 */
//-降级
@Component
public class DeptClientServiceFallBackFactory implements FallbackFactory {
    // 创建一个什么东西   失败创建一个 deptservice 谁调用失败 就返回谁 现在要处理的是一个类 deptservice
    @Override
    public Object create(Throwable throwable) {
        return new FeignDeptClientService() {
            @Override
            public boolean addDept(Dept dept) {
                return false;
            }

            @Override
            public Dept queryDeptById(Long id) {
                return new Dept().setDeptno(id).setDname("this id "+id+"is not found,consumer has level down message this server already fall").setDb_source("the mysql database not message");
            }

            @Override
            public List<Dept> queryAll() {
                return null;
            }
        };
    }
}
